package com.qianfeng.openapi.controller;

import com.github.pagehelper.PageInfo;
import com.qianfeng.openapi.bean.AjaxMessage;
import com.qianfeng.openapi.bean.TableData;
import com.qianfeng.openapi.pojo.ApiSystemparam;
import com.qianfeng.openapi.service.ApiSystemparamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/systemparaters")
public class ApiSystemparamController {
    @Autowired
    private ApiSystemparamService apiSystemparamService;

    @RequestMapping("/add")
    public AjaxMessage insertApiSystemparam(ApiSystemparam apiSystemparam){
        apiSystemparamService.insertApiSystemparam(apiSystemparam);
        return new AjaxMessage(true, "添加成功");
    }

    @RequestMapping("/del")
    public AjaxMessage deleteApiSystemparam(Integer[] ids){
        apiSystemparamService.deleteApiSystemparam(ids);
        return new AjaxMessage(true,"删除成功");
    }

    @RequestMapping("/update")
    public AjaxMessage updateApiSystemparam(ApiSystemparam apiSystemparam){
        apiSystemparamService.updateApiSystemparam(apiSystemparam);
        return new AjaxMessage(true,"修改成功");
    }

    @RequestMapping("/table")
    public TableData<ApiSystemparam> getAllApiSystemparam(int page, int limit, ApiSystemparam apiSystemparam){
        PageInfo<ApiSystemparam> pageInfo=apiSystemparamService.getAllApiSystemparam(page,limit,apiSystemparam);
        TableData<ApiSystemparam> tableData = new TableData<>();
        tableData.setCode(0);
        tableData.setMsg("成功");
        tableData.setCount(pageInfo.getTotal());
        tableData.setData(pageInfo.getList());

        return tableData;
    }

}
